<?php

namespace app\common\model;

use think\model\concern\SoftDelete;

class OpenaiUsage extends \think\Model
{
    use SoftDelete;

    protected $table = 'db_openai_usage';

    protected $jsonAssoc = true;

    protected $autoWriteTimestamp = true;

    protected $schema = [
        'id' => 'int',
        'create_time' => 'int',
        'update_time' => 'int',
        'delete_time' => 'int',
        'member_id' => 'int',
        'robot_id' => 'int',
        'robot_conversation_id' => 'int',
        'robot_conversation_message_id' => 'int',
        'robot_files_id' => 'int',
        'type' => 'tinyint',
        'number_of_prompt_words' => 'int',
        'number_of_response_words' => 'int',
        'prompt_unit_price' => 'double',
        'response_unit_price' => 'double',
        'prompt_money' => 'double',
        'response_money' => 'double',
        'total_money' => 'double',
        'apikey' => 'varchar',
        'model_name' => 'varchar',
        'robot_event_id' => 'int',
    ];

    public $getters = [
        
    ];

    /**
     * 关联模型member
     */
    public function member()
    {
        return $this->belongsTo(Member::class );
    }

    /**
     * 关联模型robot
     */
    public function robot()
    {
        return $this->belongsTo(Robot::class );
    }

    /**
     * 关联模型robotConversation
     */
    public function robotConversation()
    {
        return $this->belongsTo(RobotConversation::class );
    }

    /**
     * 关联模型robotConversationMessage
     */
    public function robotConversationMessage()
    {
        return $this->belongsTo(RobotConversationMessage::class );
    }

    /**
     * 关联模型robotFiles
     */
    public function robotFiles()
    {
        return $this->belongsTo(RobotFiles::class );
    }

    /**
     * 关联模型robotEvent
     */
    public function robotEvent()
    {
        return $this->belongsTo(RobotEvent::class );
    }
}
